# 导包
import pytest

from Tools.tool import read
from Po.Base import Base
from selenium.webdriver.common.by import By
import time,logging
class Page(Base):
    login_loc=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    yhm_loc=(By.NAME,'username')
    mm_loc=(By.NAME,'password')
    dl_loc=(By.CLASS_NAME,'finish-btn')
    ssl_loc=(By.XPATH,'//*[@id="searchForm"]/div[1]/input')
    ss_loc=(By.XPATH,'//*[@id="searchForm"]/div[2]/input')

    text_loc=(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/em/a')


    # 点击登录
    def login(self):
        logging.info('登录')
        self.click(self.login_loc)
    # 输入用户名
    def yhm(self):
        self.send_keys(self.yhm_loc,'1760153572')
    # 输入密码
    def mm(self):
        self.send_keys(self.mm_loc,'123456')
    # 登录成功
    def dl(self):
        self.click(self.dl_loc)

    # @pytest.mark.parametrize('b',read(r'C:\Users\Administrator\PycharmProjects\93zk\Data\buy.yaml'))
    # 搜索框输入文本
    def ssl(self):
        self.send_keys(self.ssl_loc,'蓝牙耳机')

    def sslt(self):
        self.index(self.text_loc,1)


    # 点击搜索
    def ss(self):
        self.click(self.ss_loc)

    def text1(self):
        return self.text(self.text_loc)
    # 用例
    def test_01(self):
        self.open_url('http://10.59.9.12:7001/')
        self.login()
        self.yhm()
        self.mm()
        time.sleep(8)
        self.dl()
        time.sleep(5)

        self.ssl()
        self.ss()
        a=self.text1()
        assert a == '蓝牙耳机(旗舰版)'
        print(a)
